package com.fallsvc.re.networkprogramming.threadpool;

import java.util.concurrent.*;

/**
 * @auther falls_vc
 * description:
 * @date 2025/10/29  19:32
 */
public class Demo1 {
    public static void main(String[] args) {
        ExecutorService pool = new ThreadPoolExecutor(1, 2, 1000, TimeUnit.MILLISECONDS,
                new SynchronousQueue<Runnable>(),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy());
        for(int i=0;i<3;i++) {
            pool.submit(new Runnable() {

                @Override
                public void run() {
                    System.out.println("hello!");
                }
            });
        }
    }
    public static void main1(String[] args) {
        ExecutorService pool = Executors.newFixedThreadPool(4);
        ExecutorService pool1 = Executors.newCachedThreadPool();
        ExecutorService pool2 = Executors.newSingleThreadExecutor();
        ScheduledExecutorService pool3 = Executors.newScheduledThreadPool(2);
        pool.submit(()->{
            System.out.println("hello");
        });
        pool3.schedule(()->{
            System.out.println("hlll");
        },10, TimeUnit.SECONDS);
    }
}
